package presencial2014;
import java.util.Scanner;

public class B {

	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		while (in.hasNext()) {
			String linea = in.nextLine();
			String[] palabra = linea.split(" ");

			boolean ok = true;
			String palabraAnt = palabra[0];
			for (int i = 1; i < palabra.length && ok; i++) {
				String palabraAct = palabra[i];
				ok = extraerPpio(palabraAct).equals(extraerFin(palabraAnt));
				palabraAnt = palabraAct;
			}
			if (ok) {
				System.out.println("SI");
			} else {
				System.out.println("NO");
			}
		}
	}

	private static String extraerFin(String palabra) {
		String sol = palabra.substring(palabra.length() - 2, palabra.length());
		return sol;
	}

	private static String extraerPpio(String palabra) {
		String sol = palabra.substring(0, 2);
		return sol;
	}

}
